import { EventTouch, Node } from 'cc';
import { BaseView } from '../BaseView';

/**
 * - 作者: DoooReyn
 * - 日期: 2023.11.02
 * - 名称: HintStack
 * - 描述: 提示堆栈基类
 */
export class HintStack extends BaseView {
    protected onLoad(): void {
        super.onLoad();
        this.node.on(Node.EventType.CHILD_ADDED, this.onCheckInteractable, this);
        this.node.on(Node.EventType.CHILD_REMOVED, this.onCheckInteractable, this);
        this.node.on(Node.EventType.TOUCH_START, this.onTouchScreen, this);
        this.onCheckInteractable();
    }

    /** 屏幕被点击时调用 */
    protected onTouchScreen(e: EventTouch) {
        e.propagationStopped = true;
        this.logger.debug('被点击');
    }

    /** 是否可交互 */
    protected get interactable() {
        return this.node.children.length > 0;
    }

    /** 检查是否可交互 */
    protected onCheckInteractable() {
        this.node.active = this.interactable;
    }
}
